package jme3testing.helloworld;
 
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.math.Vector2f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.shape.Line;
import com.jme3.scene.shape.Dome;
import com.jme3.light.DirectionalLight;
import com.jme3.scene.shape.Cylinder;
import com.jme3.scene.shape.*;
import com.jme3.util.BufferUtils;
import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer.Type;
import com.jme3.math.*;

/** Sample 1 - how to get started with the most simple JME 3 application.
 * Display a blue 3D cube and view from all sides by
 * moving the mouse and pressing the WASD keys. */
 
 /*-----------------------------------------------
  NOTE: This class has the Triangular prism, Hexagonal Prism, and rectangular pyramid
  ------------------------------------------------
  */
  
public class triangularPrism extends SimpleApplication {
 
    public static void main(String[] args){
        triangularPrism app = new triangularPrism();
        app.start(); // start the game
    }
 
    @Override
    public void simpleInitApp() {
       /*
        Mesh m = new Mesh();
        //vertices of triangular prism
        Vector3f [] vertices = new Vector3f[6];
        vertices[0] = new Vector3f(0,0,0);
        vertices[1] = new Vector3f(3,0,0);
        vertices[2] = new Vector3f(1.5f, 2,0);
        vertices[3] = new Vector3f(0,0,-3);
        vertices[4] = new Vector3f(3,0,-3);
        vertices[5] = new Vector3f(1.5f, 2, -3);
        
        //texture coordinates
        Vector2f[] texCoord = new Vector2f[6];
        texCoord[0] = new Vector2f(0,0);
        texCoord[1] = new Vector2f(1,0);
        texCoord[2] = new Vector2f(0,1);
        texCoord[3] = new Vector2f(1,1);
        texCoord[4] = new Vector2f(0,0);
        texCoord[5] = new Vector2f(1,0);
        
        
        int [] indexes = { 1,2,0, 3,5,4, 0,3,4, 4,1,0, 4,5,2, 2,1,4, 5,3,0, 0,2,5};
        
        m.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(vertices));
        m.setBuffer(Type.TexCoord, 2, BufferUtils.createFloatBuffer(texCoord));
        m.setBuffer(Type.Index,    1, BufferUtils.createIntBuffer(indexes));
        m.updateBound();
        
        Geometry triangleMesh = new Geometry("ourmesh",m);
        //Common/MatDefs/Misc/ShowNormals.j3md rainbow colors
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
        //mat.setColor("Color",ColorRGBA.Red);
        triangleMesh.setMaterial(mat);
        rootNode.attachChild(triangleMesh);*/
        
        
        Mesh hexMesh = new Mesh();
        Vector3f [] vertices = new Vector3f[12];
        vertices[0] = new Vector3f(0,1,0);
        vertices[1] = new Vector3f(1,0,0);
        vertices[2] = new Vector3f(2,0,0);
        vertices[3] = new Vector3f(3,1,0);
        vertices[4] = new Vector3f(2,2,0);
        vertices[5] = new Vector3f(1,2,0);
        vertices[6] = new Vector3f(0,1, -2);
        vertices[7] = new Vector3f(1,0,-2);
        vertices[8] = new Vector3f(2,0,-2);
        vertices[9] = new Vector3f(3,1,-2);
        vertices[10] = new Vector3f(2,2,-2);
        vertices[11] = new Vector3f(1,2,-2);
        
        //texture coordinates
        /*
        Vector2f[] texCoord = new Vector2f[6];
        texCoord[0] = new Vector2f(0,0);
        texCoord[1] = new Vector2f(1,0);
        texCoord[2] = new Vector2f(0,1);
        texCoord[3] = new Vector2f(1,1);
        texCoord[4] = new Vector2f(0,0);
        texCoord[5] = new Vector2f(1,0);*/
        
        //lines separating front, back ,bottom, bottom right, top right
        //top, top left, bottom left
        int [] indexes = {5,0,1, 2,3,4, 4,5,1, 1,2,4, 
        7,6,11, 10,9,8, 7,11,10, 10,8,7,  
        2,1,7, 7,8,2,
        2,8,9, 9,3,2,  
        3,9,10, 10, 4, 3,   
        4,10,11, 11,5,4,
        5,11,6, 6,0,5,
        0,6,7, 7,1,0};

        hexMesh.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(vertices));
        //hexMesh.setBuffer(Type.TexCoord, 2, BufferUtils.createFloatBuffer(texCoord));
        hexMesh.setBuffer(Type.Index,    1, BufferUtils.createIntBuffer(indexes));
        hexMesh.updateBound();
        
        Geometry hexGeom = new Geometry("ourmesh",hexMesh);
        //Common/MatDefs/Misc/ShowNormals.j3md rainbow colors
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
        //mat.setColor("Color",ColorRGBA.Red);
        hexGeom.setMaterial(mat);
        rootNode.attachChild(hexGeom);
        /*
        Mesh rPyramidMesh = new Mesh();
        Vector3f [] vertices = new Vector3f[5];
        vertices[0] = new Vector3f(0,0,0);
        vertices[1] = new Vector3f(2,0,0);
        vertices[2] = new Vector3f(2,0,2);
        vertices[3] = new Vector3f(0,0,2);
        vertices[4] = new Vector3f(1,2,1);
        
        //texture coordinates
        Vector2f[] texCoord = new Vector2f[5];
        texCoord[0] = new Vector2f(0,0);
        texCoord[1] = new Vector2f(1,0);
        texCoord[2] = new Vector2f(0,1);
        texCoord[3] = new Vector2f(1,1);
        texCoord[4] = new Vector2f(0,0);
        //index faces: bottom,front, right, back, left
         int [] indexes = {2,1,0, 0,3,2,
             0,1,4, 
             1,2,4,
             3,4,2, 
             0,3,4};
        rPyramidMesh.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(vertices));
        rPyramidMesh.setBuffer(Type.TexCoord, 2, BufferUtils.createFloatBuffer(texCoord));
        rPyramidMesh.setBuffer(Type.Index,    1, BufferUtils.createIntBuffer(indexes));
        rPyramidMesh.updateBound(); 
        
        Geometry rPyramidGeom = new Geometry("ourmesh",rPyramidMesh);
        //Common/MatDefs/Misc/ShowNormals.j3md rainbow colors
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
        //mat.setColor("Color",ColorRGBA.Red);
        rPyramidGeom.setMaterial(mat);
        rootNode.attachChild(rPyramidGeom);*/
    }
}